import { browserHistory } from 'react-router';
import store from './store';

import { syncHistoryWithStore } from  'react-router-redux';
import Common from 'components/Common';
const load = (moduleName) => {
    const module = require(`views/${moduleName}/index.js`);
    return module.default;
};

const history = syncHistoryWithStore(browserHistory,store);
export default {
    path: '/',
    component:Common,
    indexRoute: {
        component: load('Home'),
        params: {bottomBar: 1},
    },
    onEnter(){
        let cur_path  =history.getCurrentLocation().pathname;
    },

    childRoutes: [
        //demo
        {
            path:'demo/add',
            component:load("Demo")
        },
        {
            path:'demo/edit/:id',
            component:load("Demo")
        },

        // 轮播图
        {
            path:'carousel/add_carousel',                             // 添加
            component:load("ActivityManage/Carousel/Add")             // 编辑
        },
        {
            path:'carousel/edit_carousel/:id',
            component:load("ActivityManage/Carousel/Add")
        },

        // 商品列表
        {
            path:'goods_list/add_goods',
            component:load("GoodsManage/List/Add")
        },
        {
            path:'goods_list/edit_goods/:id',
            component:load("GoodsManage/List/Add")
        },

        // 商品分类
        {
            path:'goods_category/add_category',
            component:load("GoodsManage/Category/AddCategory")
        },
        {
            path:'goods_category/edit_category/:id',
            component:load("GoodsManage/Category/AddCategory")
        },

        // 商品类型
        {
            path:'goods_category/add_genre',
            component:load("GoodsManage/Genre/AddGenre")
        },
        {
            path:'goods_category/edit_genre/:id',
            component:load("GoodsManage/Genre/AddGenre")
        },

        // 商品规格
        {
            path:'goods_spec/add_spec',
            component:load("GoodsManage/Specification/AddSpec")
        },
        {
            path:'goods_spec/edit_spec/:id',
            component:load("GoodsManage/Specification/AddSpec")
        },


        // 专题活动
        {
            path:'thematic/add_activity',
            component:load("Thematic/AddActivity")
        },
        {
            path:'thematic/edit_activity/:id',
            component:load("Thematic/AddActivity")
        },

        // 抢购活动
        {
            path:'snap_up/add_snap_up',
            component:load("Thematic/SnapUp/AddSnapUp")
        },
        {
            path:'snap_up/edit_snap_up/:id',
            component:load("Thematic/SnapUp/AddSnapUp")
        },

        // 砍价活动
        {
            path:'bargain/add_bargain',
            component:load("Thematic/Bargain/AddBargain")
        },
        {
            path:'bargain/edit_bargain/:id',
            component:load("Thematic/Bargain/AddBargain")
        },


        // -------
        {
            path:'403',
            component:load("Exception/403")
        },
        {
            path:'login',
            component: load("Login")
        },
        {
            path:'admin',
            component: load("Admin")
        },
        {
            path:'admin/add',
            component: load("Admin/Add")
        },
        {
            path:'admin/edit/:id',
            component: load("Admin/Add")
        },
        {
            path:'role',
            component: load("Admin/Role")
        },
        {
            path:'role/add',
            component: load("Admin/RoleAdd")
        },
        {
            path:'role/edit/:id',
            component:load("Admin/RoleAdd")
        },
        {
            path:'merchant',
            component:load("Merchant")
        },
        {
            path:'merchant/add',
            component:load("Merchant/Add")
        },
        {
            path:'merchant/edit/:id',
            component:load("Merchant/Add")
        },
        {
            path:'appcate',
            component:load("AppCate")
        },
        {
            path:'appcate/add',
            component:load("AppCate/Add")
        },
        {
            path:'appcate/edit/:id',
            component:load("AppCate/Add")
        },
        {
            path:'app',
            component:load("App")
        },
        {
            path:'app/add',
            component:load("App/Add")
        },
        {
            path:'app/edit/:id',
            component:load("App/Add")
        }



    ]
}
